﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace Collatz_01_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            for (BigInteger i=2; i < 100; i++)
            {
                Console.WriteLine(i + ":");
                foreach (var getal in Collatz(i))
                {
                    Console.WriteLine(getal);
                }
                Console.WriteLine("---------------------------");
            }

            Console.ReadLine();
        }

        static IEnumerable<BigInteger> Collatz(BigInteger getal)
        {
            while (!getal.IsOne)
            {
                if (getal.IsEven)
                {
                    getal = getal / 2;
                }
                else
                {
                    getal = getal * 3 + 1;
                }
                yield return getal;
            }
        }
    }
}
